package cool.zhang.repository;

import cool.zhang.model.Movie;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by chemeng on 2017/3/10.
 */
public interface MovieRepository extends JpaRepository<Movie,Integer> {
    List<Movie> findByName(String name);

    List<Movie> findByDirector(String director);

    List<Movie> findByNameAndDirector(String name,String director);

    @Query(value = "select m from Movie m where m.name=:name and m.director=:director")
    List<Movie> withNameAndDirectorQuery(@Param("name")String name,@Param("director")String director);
}
